{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "孙悟空的兵器是“金箍棒”\n",
      "假悟空的兵器是“金箍棒”\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(None, None)"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#其实这边用类不太合适，因为只有一个，不过瞎扯，无所谓了\n",
    "\n",
    "\n",
    "class SmartMonkey(object):    #不知道怎么描述，这是孙悟空，灵明石猴\n",
    "    \n",
    "    def __init__(self,name):\n",
    "        self.name = name\n",
    "        \n",
    "    def decorate(self):\n",
    "        print(f'{self.name}被套上了“紧箍咒”，会疼')\n",
    "        \n",
    "    def Weapon(self):\n",
    "        print(f'{self.name}的兵器是“金箍棒”')\n",
    "        \n",
    "    def skill(self):\n",
    "        print(f'{self.name}会火眼金睛和七十二变')\n",
    "        \n",
    "    def experience(self):\n",
    "        print(f'{self.name}曾经大闹天宫和地府')\n",
    "        \n",
    "    def mirror(self):\n",
    "        print(f'{self.name}是真的美猴王')\n",
    "\n",
    "\n",
    "class SixMonkey(SmartMonkey):      #这是六耳猕猴\n",
    "    \n",
    "    def __init__(self,name):\n",
    "        super().__init__(name)\n",
    "        self.__appearance = 'six ear'\n",
    "    \n",
    "    def __appearances(self):\n",
    "        print(f'{self.name} has {self.__appearance}')\n",
    "        \n",
    "        \n",
    "wukong = SmartMonkey('孙悟空')\n",
    "fake_wukong = SixMonkey('假悟空')\n",
    "\n",
    "\n",
    "wukong.Weapon(),fake_wukong.Weapon()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'six ear'"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fake_wukong._SixMonkey__appearance"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "假悟空 has six ear\n"
     ]
    }
   ],
   "source": [
    "fake_wukong._SixMonkey__appearances()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'SixMonkey' object has no attribute '__appearances'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-53-d8d3cabfb0a3>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mfake_wukong\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__appearances\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m: 'SixMonkey' object has no attribute '__appearances'"
     ]
    }
   ],
   "source": [
    "fake_wukong.__appearances()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
